package com.utils;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class WriterLogger {

    //切入点的注解
    @Pointcut("execution(* com.service..*.*(..))")
    public void pointCut(){ }

    /**
     * 异常增强
     * @param jp
     * @param e
     */
    @AfterThrowing(pointcut = "pointCut()",throwing = "e")
    public void throwExceptionMethod(JoinPoint jp, Exception e){
        System.out.println("执行了"+jp.getSignature()+"方法，出现异常："+e.getMessage());
    }
}
